<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>骡窝窝系统管理平台</title>
    <#include "../common/header.ftl"/>

    <script type="text/javascript">
        $(function(){

            $("#query").click(function(){
                $("#currentPage").val();
                $("#searchForm").submit();
            });
                //模态框

            $(".showBtn").click(function(){
                $('#editForm input').val("");
                var obj=$(this).data("json");
                console.log(obj);
                if(obj){
                    $('#editForm input[name="id"]').val(obj.id);
                    $('#editForm input[name="title"]').val(obj.title);
                    $('#editForm input[name="subTitle"]').val(obj.subTitle);
                    $('#editForm select[name="state"]').val(obj.state);
                    $('#editForm select[name="place.id"]').val(obj.placeId);
                    $('#editForm input[name="coverUrl"]').val(obj.coverUrl);
                    $('#coverUrl').attr('src',obj.coverUrl);
                    $('#skip').attr('href',"/release/list.do?travelId="+obj.travelId);

                }
                $('#showModal').modal('show')
            });

        });
    </script>
</head>

<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "strategy" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>大攻略管理</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/strategy/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <div class="form-group">
                    </div>
                    <div class="form-group">
                        <label>关键字</label>
                        <input class="form-control" type="text" name="keyword" value="${(qo.keyword)!''}">
                    </div>
                    <div class="form-group">
                        <button id="query" type="button" class="btn btn-success"><i class="icon-search"></i> 查询</button>
                    </div>
                </form>
            </div>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>标题</th>
                        <th>封面</th>
                        <th>副标题</th>
                        <th>所属地区</th>
                        <th>状态</th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
					<#list pageInfo.list as vo>
                    <tr>
                        <td>${vo_index+1}</td>
                        <td>${vo.title!""}</td>
                        <td><img src='${vo.coverUrl!""}' width="30px"/></td>
                        <td>${vo.subTitle!""}</td>
                        <td>${vo.place.name}</td>
                        <td>
                        <#if vo.state == -1>
                            禁用
                        <#elseif vo.state == 0>
                            普通
                        <#elseif vo.state == 1>
                            推荐
                        </#if>
                        </td>
                        <td>
                            <a href="javascript:" class="btn btn-info btn-xs showBtn" data-json='${vo.json}'>
                                <span class="glyphicon glyphicon-pencil"></span> 修改
                            </a>

                       </td>
                    </tr>
					</#list>
                    </tbody>
                </table>

                 <#include "../common/page.ftl"/>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="showModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">游记修改</h4>
            </div>
            <div class="modal-body">

                <form class="form-horizontal" action="/strategy/saveOrUpdate.do" method="post" id="editForm" enctype="multipart/form-data">
                    <input type="hidden"  name="id">
                    <div class="form-group" >
                        <label for="name" class="col-sm-4 control-label">标题：</label>
                        <div class="col-lg-7">
                            <input type="text" class="form-control"  name="title" >
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">封面：</label>
                        <div class="col-lg-7">
                            <img id="coverUrl">
                            <input type="file" class="form-control"  name="file" >
                            <input type="hidden" class="form-control"  name="coverUrl" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">副标题：</label>
                        <div class="col-lg-7">
                            <input type="text" class="form-control"  name="subTitle"  >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">所属地区：</label>
                        <div class="col-lg-7">
                            <select  name="place.id" id="place" class="form-control form-control-chosen" >
                               <#list regions as r>
                                   <option value="${r.id}">${r.name}</option>
                               </#list>
                            </select>

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">状态：</label>
                        <div class="col-lg-7">
                            <select class="c-select form-control" name="state" >
                                <option value="-1">禁用</option>
                                <option value="0">普通</option>
                                <option value="1">推荐</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" style="text-align: center">
                        <a target="_blank" id="skip">点击查看文章详细信息</a>
                    </div>
                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary submitBtn">保存</button>
            </div>
        </div>
    </div>

</div>
<style>
    #showModal img{
        width:100%
    }
    #showModal  .modal-body{
        max-height: 600px;
        overflow-y: auto;
    }

</style>
</body>
</html>